package cn.wx.scholar;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.SecureRandom;

import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;

import cn.wx.common.utils.MyX509TrustManager;
import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.OkHttpClient.Builder;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;


public class HttpTest2 {
	

	public static void main(String[] args) throws NoSuchAlgorithmException, NoSuchProviderException, KeyManagementException {

		OkHttpClient client = new OkHttpClient();

		MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
		RequestBody body = RequestBody.create(mediaType, "Query=Composite(F.FN%20%3D%3D%20'1000%20genome)&Filters=Pt%20%3D%20'2'&Limit=1000&Offset=0&OrderBy=&SortAscending=false&=");
		Request request = new Request.Builder()
		
		.url("https://academic.microsoft.com/api/search/GetEntityResults")
		.post(body)
		.addHeader("content-type", "application/x-www-form-urlencoded")
		.addHeader("Cookie", "A=I&I=AxUFAAAAAADcBgAAppxkMXdDMh8WbdW6REgxYA!!&V=4; MC1=GUID=b696858225fe44c09863f86e57fa4c09&HASH=b696&LV=201802&V=4&LU=1519437260089; MUID=04435427E0D767D039295F68E4D76468; msacademic=143996b2-ae82-4969-b7ce-6130b0cf5bab; ai_user=lXzhe|2018-07-12T02:39:50.922Z; _ga=GA1.2.1293331498.1532580770; optimizelyEndUserId=oeu1533104931073r0.32495626027565705; _gid=GA1.2.656390118.1536651064; MS-CV=hOV9oOG+lEq5qhM7.1; ARRAffinity=9a0da02f1d53d0f119874c7a700758edc589bffa9ac51b6216b0d6687ec58ee90f111; ai_session=GG8NK|1536709208620111|1536709262678111")
		.build();
		
		try {
			Response response = client.newCall(request).execute();

			if(response.isSuccessful()){
	            System.out.println(response.code());
	            System.out.println(response.body().string());
	            
	            
	        }
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
}
